// mock/api.ts
import axios from 'axios';

// 定义全年气温数据接口
export interface AnnualTemperatureData {
    [year: number]: number[];
}

// 定义全年气温数据响应接口
export interface AnnualTemperatureResponse {
    data: number[];
}

// 定义当月气温数据接口
export interface MonthlyTemperatureData {
    [year: number]: {
        [month: number]: number[];
    };
}

// 定义当月气温数据响应接口
export interface MonthlyTemperatureResponse {
    data: number[];
}

// 模拟获取全年气温数据接口
export const getAnnualTemperatureData = async (city: string, year: number): Promise<AnnualTemperatureResponse> => {
    const mockAnnualData: { [city: string]: AnnualTemperatureData } = {
        "桂林市": {
            2023: [10, 12, 15, 13, 11, 14, 16, 17, 18, 19, 20, 21],
            2024: [11, 13, 16, 14, 12, 15, 17, 18, 19, 20, 21, 22]
        },
        "贺州市": {
            2023: [8, 10, 13, 11, 9, 12, 14, 15, 16, 17, 18, 19],
            2024: [9, 11, 14, 12, 10, 13, 15, 16, 17, 18, 19, 20]
        },
        "柳州市": {
            2023: [9, 11, 14, 12, 10, 13, 15, 16, 17, 18, 19, 20],
            2024: [10, 12, 15, 13, 11, 14, 16, 17, 18, 19, 20, 21]
        }
    };
    return Promise.resolve({ data: mockAnnualData[city][year] });
};

// 模拟获取当月气温数据接口
export const getMonthlyTemperatureData = async (city: string, year: number, month: number): Promise<MonthlyTemperatureResponse> => {
    const mockMonthlyData: { [city: string]: MonthlyTemperatureData } = {
        "桂林市": {
            2023: {
                1: [10, 12, 15, 13, 11, 14, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31],
                2: [11, 13, 16, 14, 12, 15, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]
            },
            2024: {
                1: [12, 14, 17, 15, 13, 16, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31],
                2: [13, 15, 18, 16, 14, 17, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]
            }
        },
        "贺州市": {
            2023: {
                1: [8, 10, 13, 11, 9, 12, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31],
                2: [9, 11, 14, 12, 10, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]
            },
            2024: {
                1: [9, 11, 14, 12, 10, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31],
                2: [10, 12, 15, 13, 11, 14, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]
            }
        },
        "柳州市": {
            2023: {
                1: [9, 11, 14, 12, 10, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31],
                2: [10, 12, 15, 13, 11, 14, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]
            },
            2024: {
                1: [10, 12, 15, 13, 11, 14, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31],
                2: [11, 13, 16, 14, 12, 15, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]
            }
        }
    };
    return Promise.resolve({ data: mockMonthlyData[city][year][month] });
};